# -*- coding: utf-8 -*-
# importado do jogo Arcade Tonk Tank


import pygame, os
from pygame.locals import *

BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)

def load_image(file, colorkey=-1):
	"""loads an image, prepares it for play
	colourkey = -1 forces the left-top pixel colour to be transparent,
	use colourkey = None for non transparant surfaces """
	file = os.path.join('../images', file)
	try:
		surface = pygame.image.load(file)
	except pygame.error:
		raise SystemExit, 'Could not load image "%s" %s'%(file, pygame.get_error())
	surface = surface.convert()
	if colorkey is not None:
		if colorkey is -1:
			colorkey = surface.get_at((0,0))
		surface.set_colorkey(colorkey, RLEACCEL)
	return surface

def load_transparency(file):
	file = os.path.join('../images', file)
	try:
		surface = pygame.image.load(file)
	except pygame.error:
		raise SystemExit, 'Could not load image "%s" %s'%(file, pygame.get_error())
	surface = surface.convert_alpha()
	return surface
	

def load_images(*files):
	imgs = []
	for file in files:
		imgs.append(load_image(file))
	return imgs

def load_background(file, colorkey=-1):
	"""loads an image, prepares it for play
	colourkey = -1 forces the left-top pixel colour to be transparent,
	use colourkey = None for non transparant surfaces """
	file = os.path.join('Backgrounds', file)
	try:
		surface = pygame.image.load(file)
	except pygame.error:
		raise SystemExit, 'Could not load image "%s" %s'%(file, pygame.get_error())
	surface = surface.convert()
	if colorkey is not None:
		if colorkey is -1:
			colorkey = surface.get_at((0,0))
		surface.set_colorkey(colorkey, RLEACCEL)
	return surface
	
def load_backgrounds(*files):
	imgs = []
	for file in files:
		imgs.append(load_image(file))
	return imgs

def resize(size,const):
	return (int(size[0]*const),int(size[1]*const))
